package sy.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * SysUser entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "wy_user", catalog = "ssh")
public class WYUser implements java.io.Serializable {

	// Fields

	private String id;
	private WYAccount wyAccount;
	private String name;
	private String code;
	private String telephone;
	private String identity;
	private String sex;
	
	
	@JsonProperty(value = "wyAccountName")
    private String wyAccountName;

	/** default constructor */
	public WYUser() {
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.string")
	@Id
	@Column(name = "id", unique = true, nullable = false, length = 64)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "wyAccount")
	public WYAccount getWyAccount() {
		return wyAccount;
	}

	public void setWyAccount(WYAccount wyAccount) {
		this.wyAccount = wyAccount;
	}
	
	@Column(name = "name")
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "code")
	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(name = "telephone")
	public String getTelephone() {
		return this.telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	@Column(name = "identity")
	public String getIdentity() {
		return this.identity;
	}

	public void setIdentity(String identity) {
		this.identity = identity;
	}

	@Column(name = "sex")
	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}
	
	@Transient
	public String getWyAccountName() {
		if (getWyAccount()==null){
			return "";
		}
		return getWyAccount().getName();
	}

	public void setWyAccountName(String wyAccountName) {
		this.wyAccountName = wyAccountName;
	}
	

}